/**
 * 系统配置
 */

class SystemController extends BasicController {

    async actionWeappQrcode() {

        let { page, scene } = $_POST;

        let $Weapp = wechat.get_instance("weapp", {
            appid: global.APP_ID,
            appsecret: global.APP_SECRET
        });

        console.log(global.APP_ID)

        let result = await $Weapp.weappQrcode(page, scene);
        if (result) {
            let base64 = Buffer.from(result, 'binary').toString('base64');
            return 'data:image/png;base64,' + base64;
        } else {
            throw new Error('获取失败');
        }
    }

    async actionMsg(){
        return await this.modules("Setting.SystemMsg").first();
    }
}

export default SystemController;